<?php
// 链接
$servername="localhost";
$username="root";
$password="root";
$dbname="liuyanban";
$id=$_GET["id"];
$conn=new mysqli("localhost","root","root","liuyanban");
if($conn->connect_error){
    die("连接失败:" .$conn->connect_error);
}
$sql="SELECT * FROM `liuyan` WHERE `name` LIKE '%小%' ";
$result=$conn->query($sql);

?>


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>首页</title>
</head>
<body>
    <div class="box">
        <h1 class="liu">留言板</h1>
        <div>
            <form action="add.php" method="get" >
                <textarea name="text" cols="30" rows="10" placeholder="您想说点什么..." class="kongbai"></textarea>
                <p><input type="text" name="name" placeholder="请输入你的名字" class="fa1"></p>
                <p><input type="submit" value="发表" class="fa"></p>
            </form>
        </div>
        <div class="box1">
            <ul>
            <h2 class="yan">留言内容</h2>
                <?php
                $sql = "SELECT * FROM `liuyan` ORDER BY `liuyan`.`id` DESC";
                $result = $conn->query($sql);

                    if($result->num_rows>0){
                        while($row=$result->fetch_assoc()){
                             
                            echo "<li>";
                            echo "姓名：";
                            echo $row["name"];
                            echo "<br>";
                            echo "内容：";
                            echo $row["text"];
                            echo "<br>";
                            echo "时间：";
                            echo $row["tiem"];
                            echo "<br>";
                            echo "<a href='add1.php?id={$row['id']}&name={$row['name']}&text={$row['text']}'>编辑</a>";
                            echo "<a href='shanchu.php?id={$row['id']}'>  删除</a>";
                            echo "<br>";
                            // echo "对当前留言点赞的用户：";
                            
                            
                        }
                   
                    }else{
                        echo "0 数据";
                    }
                    
                ?>
               
            </ul>
        </div>
    </div>
</body>
</html>

<style>
*{
    margin:0;
    padding:0;
}
.box{
    background-image:url(tu.png);
    width:1000px;
    height:460px;
    margin:0 auto;
}
.box1{
    padding-top:20px;
}
li{
    background:#F5F5F5;
    text-shadow:5px 5px 5px 5px;
    list-style:none;
    text-align:center;
    /* width:1000px; */
}
.liu{
    text-align:center;
}
.kongbai{
    margin-left:150px;
    margin-right:150px;
    width:700px;
    height:300px;
}
.fa{
    margin-left:150px;
    margin-right:150px;
    width:700px;
    height:50px;
    margin-top:10px;
}
.fa1{
    margin-left:150px;
    margin-right:150px;
    width:700px;
    height:20px;
}
.yan{
    /* margin-left:150px; */
    background-image:url(tu1.jpg);
}
</style>

